package com.alibaba.travel.article.controller;

import java.util.Arrays;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import com.alibaba.travel.article.entity.ColumnArticleRelationEntity;
import com.alibaba.travel.article.service.ColumnArticleRelationService;
import com.alibaba.travel.common.utils.PageUtils;
import com.alibaba.travel.common.utils.R;



/**
 * 文章专栏关系表
 *
 * @author wherezy
 * @email wherezy@tom.com
 * @date 2023-02-27 09:17:25
 */
@Api(tags = {"文章专栏关系表ColumnArticleRelationController"})
@RestController
@RequestMapping("article/columnarticlerelation")
public class ColumnArticleRelationController {
    @Autowired
    private ColumnArticleRelationService columnArticleRelationService;



    /**
     * 列表
     */
    @ApiOperation(value="分页获取信息", notes="k-v map形式封装分页参数")
    @PostMapping("/list")
    public R list(@RequestBody Map<String, Object> params){
        PageUtils page = columnArticleRelationService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @ApiOperation(value="获取信息")
    @GetMapping("/info/{id}")
    public R info(@PathVariable("id") Long id){
		ColumnArticleRelationEntity columnArticleRelation = columnArticleRelationService.getById(id);

        return R.ok().put("columnArticleRelation", columnArticleRelation);
    }

    /**
     * 保存
     */
    @ApiOperation(value="保存")
    @PostMapping("/save")
    public R save(@RequestBody ColumnArticleRelationEntity columnArticleRelation){
		columnArticleRelationService.save(columnArticleRelation);

        return R.ok();
    }

    /**
     * 修改
     */
    @ApiOperation(value="修改")
    @PostMapping("/update")
    public R update(@RequestBody ColumnArticleRelationEntity columnArticleRelation){
		columnArticleRelationService.updateById(columnArticleRelation);

        return R.ok();
    }

 /*   *//**
     * 分页查看历史点赞景点
     * @param id
     * @param page
     * @param pageSize
     * @return
     *//*
    @ApiOperation(value="修改")
    @PostMapping("/SelectLikesSpot/{userId}")
    public R SelectLikesSpot(@PathVariable("userId") Long id,@RequestParam("page") Integer page
            ,@RequestParam("pageSize") Integer pageSize){
        return userScenicLikesRelationService.selectLikesSpot(id,page,pageSize);

    }*/



    /**
     * 删除
     */
    @ApiOperation(value="删除")
    @PostMapping("/delete")
    public R delete(@RequestBody Long[] ids){
		columnArticleRelationService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
